﻿window.ClosePopup = function () {
    $('.popup').hide();
    $('.popup iframe').attr('src', 'Loading.aspx');
}

$(function () {

    $('.popup-back, .popup .icon-close').click(function () {
        window.ClosePopup();
    });
    $('a[href]').filter(function (i, a) {
        var $a = $(a);
        return $a.attr('href').indexOf('mod=popup') > 0;
    }).each(function () {
        AttachPopup($(this));
    });
});

function AttachPopup(a, validateLink) {
    if (validateLink && a.attr('href').indexOf('mod=popup') < 0) return;
    if (a.data('have-popup')) return;
    a.data('have-popup', true);
    a.click(function (e) {
        e.preventDefault();
        ShowPopup($(this).attr('href'));
    });
}

function ShowPopup(url) {
    $('.popup iframe').attr('src', url);
    $('.popup').show();
}